home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / dev / e / amigae33a.lha / E_v3.3a / Src.lha / Src / Afc / PatternMatch_Example.e < prev    next >
Text File  |  1997-09-09  |  1KB  |  48 lines

  1. /*
  2. ** DirList_Example 2
  3. **
  4. ** Methods: setdir(), read(), sort(), first(), obj()
  5. **          succ()
  6. **
  7. ** This code shows an example of parsing with pattern matching
  8. **
  9. ** This code is placed in Public Domain
  10. **
  11. ** (C)Copyright 1996/97 Amiga Foundation Classes
  12. **
  13. ** See: http://www.intercom.it/~fsoft/afc.html
  14. **
  15. **      FOR more info about AFC AND modules.
  16. **
  17. */
  18.  
  19.  
  20. MODULE 'afc/DirList',       -> Our MAGIC MODULE!
  21.        'afc/explain_exception'
  22.  
  23. PROC main() HANDLE
  24.   DEF dl:PTR TO dirlist
  25.  
  26.   NEW dl.dirlist()               -> Here we init the dirlist obj
  27.  
  28.   dl.setdir('ram:')             -> This is the working dir
  29.   WriteF('Reading...\n')
  30.   dl.read(FALSE, TRUE, '#?.info')-> Read FILES only, matching #?.info
  31.   WriteF('Sorting!\n')
  32.   dl.sort()                      -> NOTE: This sort is CASE sensitive
  33.  
  34.   WriteF('Done!\n--------------\n')
  35.  
  36.   IF dl.first()                  -> Here we pos TO the first item
  37.     REPEAT
  38.       WriteF('\s\n',dl.obj())    -> Here we show the name
  39.     UNTIL dl.succ()=FALSE        -> AND get the succ()
  40.   ENDIF
  41.  
  42. EXCEPT DO
  43.   END dl
  44.   explain_exception()
  45.   CleanUp(0)
  46. ENDPROC
  47.  
  48.